package cz.matasek.dbLogger.database;

/**
 * Oracle database.
 *
 * @author Luboš Matásek
 */
public class Oracle extends AbstractDatabaseConnection {

    /**
     * Default port for the Oracle database.
     */
    private static final int DEFAULT_PORT = 1521;
    /**
     * Database platform name.
     */
    private static final String DATABASE_PLATFORM_NAME = "Oracle";
    /**
     * JDBC driver class name.
     */
    private static final String JDBC_DRIVER_NAME = "oracle.jdbc.driver.OracleDriver";
    /**
     * Trigger variable escape char.
     */
    private static final String TRIGGER_VARIABLE_ESCAPE_CHAR = ":";
    /**
     * On update triggers support.
     */
    private static final boolean SUPPORTS_ON_UPDATE_TRIGGERS = true;

    /**
     * Creates a new Oracle database object with specified parameters.
     *
     * @param username database username
     * @param password database password
     * @param host database host
     * @param sid Oracle SID
     * @param port database port
     */
    public Oracle(String username, String password, String host, String sid, String port) {
        super(DatabasePlatform.ORACLE, username, password, host, sid, port);
    }

    /**
     * Returns default port number for the database.
     *
     * @return default port number
     */
    public static int getDefaultPort() {
        return Oracle.DEFAULT_PORT;
    }

    /**
     * Returns Oracle database platform name.
     *
     * @return database platform name
     */
    public static String getDatabasePlatformName() {
        return Oracle.DATABASE_PLATFORM_NAME;
    }

    @Override
    public String getJdbcDriverName() {
        return Oracle.JDBC_DRIVER_NAME;
    }

    @Override
    public String getJdbcConnectionString() {
        return "jdbc:oracle:thin:@" + host + ":" + port + "/" + databaseName;
    }

    @Override
    protected String getTriggerVariableEscapeChar() {
        return Oracle.TRIGGER_VARIABLE_ESCAPE_CHAR;
    }

    @Override
    public boolean supportOnUpdateTriggers() {
        return Oracle.SUPPORTS_ON_UPDATE_TRIGGERS;
    }
}
